<%@ page pageEncoding="utf-8" contentType="text/html; charset=utf-8"%> 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd style="text-align:center"">
<html>
<head>
<title>称号管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<script type="text/javascript">
function addHonor() {
	var params = {
			playerId : $("#playerId").val(),
			honorId : $("#honor").val(),
			honorText : $("#honor").find("option:selected").text(),
			validTime : $("#validTime").val()
		};
		$.getJSON("/admin/honor/add.do",params,function(data){
			if(data.msg=="success") {
				location.reload();
			} else {
				alert(data.msg);
			}
		});
}

function honorDel(playerId,honorId) {
	if(confirm("确定回收？")) {
		var params = {
			playerId : playerId,
			honorId : honorId
		};
		$.getJSON("/admin/honor/del.do",params,function(data){
			if(data.msg=="success") {
				location.reload();
			} else {
				alert(data.msg);
			}
		});
	}
	
}
</script>
</head>
<body>
<div>
	<form id="form1" name="form1" method="post" action="" style="padding:0 0 10px 0">
		玩家ID:<input name="playerId" id="playerId" value="" type="text"/>
		称号名称：<select id="honor">
			<c:forEach var="h" items="${honors}">
				<c:if test="${h.id > 6000 && h.id < 20000}">
				<option value="${h.id}">${h.name}</option>
				</c:if>
			</c:forEach>
		</select>
		<div class="datepicker input-append">
		<input data-format="yyyy-MM-dd" name="endDate" id="validTime" value="" type="text"></input>
		<span class="add-on">
			<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
		</span>
	</div> &nbsp;&nbsp;&nbsp;&nbsp;
		<input type="button" name="button1" id="button" value="发放" class="btn" onclick="addHonor()"/>
	</form>
	</div>
	<table class="table table-bordered">
		<thead>
			 <tr style=" background-color:#CCCCFF">
			<td width="150"><strong>称号ID</strong></td>
			<td><strong>称号名称</strong></td>
			<td><strong>玩家</strong></td> 
			<td><strong>有效至</strong></td>  
			<td><strong>操作</strong></td>  	 		 
			</tr>
		</thead>
		<tbody id="body_id">
		<c:forEach var="entry" items="${data}">
			<tr>
				<td>${entry.honorId}</td>
				<td>${entry.honorText}</td>
				<td><tags:user id="${entry.playerId}"/></td>
				<td>
					<c:if test="${entry.validTime!='0'}">${entry.validTime}</c:if>&nbsp;
					<c:if test="${entry.isValid==0}"><font color="FF0000">请回收</font></c:if>
				</td>
				<td>
					<c:if test="${entry.validTime!='0'}">
						<a href="javascript:void()" onclick="javascript:honorDel(${entry.playerId},${entry.honorId})">回收</a>
					</c:if>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
</body>
</html>